home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / boot / czesc_2 / onekeyii / src / wintext.c < prev    next >
C/C++ Source or Header  |  1992-11-22  |  2KB  |  83 lines

  1. /*
  2. *    wintext.h
  3. *
  4. *    Routines for font-independent window-text system, which allows
  5. *    writing of text based on character positions.
  6. *    Still being tweaked.
  7. *
  8. *    MWS 3/92.
  9. */
  10.  
  11. #include <exec/types.h>
  12. #include <graphics/gfxmacros.h>
  13. #include <graphics/gfxbase.h>
  14. #include <intuition/intuition.h>
  15. #include <proto/graphics.h>
  16. #include <proto/intuition.h>
  17.  
  18. #include <string.h>
  19.  
  20. #include "wintext.h"
  21.  
  22. BOOL 
  23. InitWinTextInfo(WINTEXTINFO * wti)    /* for Workbench screen at moment */
  24. {
  25.     struct Screen screen;
  26.     struct TextFont *tf;
  27.  
  28.     if (GetScreenData(&screen, sizeof(screen), WBENCHSCREEN, NULL))
  29.     {
  30.     wti->tattr.ta_Name = GfxBase->DefaultFont->tf_Message.mn_Node.ln_Name;
  31.     wti->tattr.ta_YSize = GfxBase->DefaultFont->tf_YSize;
  32.  
  33.     if (tf = OpenFont(&wti->tattr))    /* have a peek */
  34.     {
  35.         wti->font_x = tf->tf_XSize;
  36.         wti->font_y = tf->tf_YSize;
  37.         wti->font_baseline = tf->tf_Baseline;
  38.         /* no dragbar, so modified toffset */
  39.         wti->toffset = screen.WBorTop + 1/*+ tf->tf_YSize*/;
  40.         wti->loffset = screen.WBorLeft + 2;
  41.         wti->roffset = screen.WBorRight + 2;
  42.         wti->boffset = screen.WBorBottom;
  43.  
  44.         CloseFont(tf);    /* should be set to rastport of window */
  45.         return TRUE;
  46.     }
  47.     }
  48.     return FALSE;
  49. }
  50.  
  51. /****** UNUSED AT MOMENT
  52. void RenderWinTexts(WINTEXTINFO *info, WINTEXT *wt)
  53. {
  54.     struct RastPort *rp;
  55.  
  56.     while (wt)
  57.     {
  58.         rp = info->window->RPort;
  59.         SetAPen(rp, wt->pen);
  60.         SetDrMd(rp, wt->mode);
  61.         Move(rp, info->loffset + wt->lpos*info->font_x,
  62.              info->toffset + wt->tpos*info->font_y + info->font_baseline);
  63.         Text(rp, wt->text, strlen(wt->text));
  64.         wt = wt->next;
  65.     }
  66. }
  67. ******/
  68.  
  69.  
  70. void 
  71. WinText(WINTEXTINFO * info, char *text,
  72.     UWORD lpos, UWORD tpos, UWORD pen, UWORD mode)
  73. {
  74.     struct RastPort *rp;
  75.  
  76.     rp = info->window->RPort;
  77.     SetAPen(rp, pen);
  78.     SetDrMd(rp, mode);
  79.     Move(rp, info->loffset + lpos * info->font_x,
  80.      info->toffset + tpos * info->font_y + info->font_baseline);
  81.     Text(rp, text, strlen(text));
  82. }
  83.